﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Iguana.Core.HypterText
{
    public class AttributeCollection : List<IAttribute>
    {

        public IAttribute this[IAttribute i]
        {
            get
            {
                return this[i];
            }
            set
            {
                this[i] = value;
            }
        }

        /// <summary>
        /// Gets or sets the value of an attribute by name.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public string this[string name]
        {
            get
            {
                IAttribute val = null;
                foreach (IAttribute i in this)
                {
                    if (i.Name == name)
                        val = i; break;
                }
                return val.Value;
            }
            set
            {
                int cnt = 0;
                foreach (var i in this)
                {                    
                    if (i.Name == name)
                    {
                        this[cnt].Value = value;
                        break;
                    }
                    cnt++;
                }
            }
        }

    }
}
